package cn.edu.cdu.group4nb.service.impl;

import cn.edu.cdu.group4nb.mapper.RecruitMapper;
import cn.edu.cdu.group4nb.mapper.RecruitmentMapper;
import cn.edu.cdu.group4nb.po.Institution;
import cn.edu.cdu.group4nb.po.Position;
import cn.edu.cdu.group4nb.po.Recruit;
import cn.edu.cdu.group4nb.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class RecruitServiceImpl implements RecruitService {
    @Autowired
    private RecruitmentMapper recruitmentMapper;
    @Autowired
    private RecruitMapper recruitMapper;

    @Override
    public List<Map<String,Object>> selectAllPositionByInstitutionId(int institutionId) {
        return recruitmentMapper.selectAllPositionByInstitutionId(institutionId);
    }

    @Override
    public Institution selectInstitutionOfLoginUser(int userInfoId){
        return recruitmentMapper.selectInstitutionOfLoginUser(userInfoId);
    }

    @Override
    public List<Position> selectPositionByInstitutionIdOfLoginUser(int userInfoId) {
        return recruitmentMapper.selectPositionByInstitutionIdOfLoginUser(userInfoId);
    }

    @Override
    public int getPositionNumByInstitutionIdAndPositionId(int institutionId,int positionId) {
        return recruitmentMapper.getPositionNumByInstitutionIdAndPositionId(institutionId,positionId);
    }
    @Override
    public void insertRecruit(Recruit record){
        recruitMapper.insert(record);
    }

    @Override
    public List<Map<String,Object>> selectAllRecruit(){
        return recruitmentMapper.selectAllRecruit();
    }

    @Override
    public int getRoleIdOfLoginUser(int userInfoId){
        return recruitmentMapper.getRoleIdOfLoginUser(userInfoId);
    }

    @Override
    public int deleteRecruitByIds(int[] recruitId){
        return recruitMapper.deleteByPrimaryKeys(recruitId);
    }

    @Override
    public int updateRecruit(Recruit record){
        return recruitMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Map<String,Object>> selectRecruitById(Integer recruitId){
        return recruitMapper.selectByPrimaryKey(recruitId);
    }

    @Override
    public int publishRecruit(Recruit record){
        return recruitmentMapper.publishRecruit(record);
    }

    @Override
    public List<Map<String,Object>> listRecruit(){
        return recruitmentMapper.listRecruit();
    }
}
